package cn.game.tanke.role;

import javax.swing.*;
import java.awt.*;

public abstract class Role {
    private Image image;
    private int imgWidth;
    private int imgHeight;

    private int step;
    private int dir;
    private int x;
    private int y;

    public Role() {
    }

    public Role(Image image, int imgWidth, int imgHeight, int step, int dir, int x, int y) {
        this.image = image;
        this.imgWidth = imgWidth;
        this.imgHeight = imgHeight;
        this.step = step;
        this.dir = dir;
        this.x = x;
        this.y = y;
    }

    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    public int getImgWidth() {
        return imgWidth;
    }

    public void setImgWidth(int imgWidth) {
        this.imgWidth = imgWidth;
    }

    public int getImgHeight() {
        return imgHeight;
    }

    public void setImgHeight(int imgHeight) {
        this.imgHeight = imgHeight;
    }

    public int getStep() {
        return step;
    }

    public void setStep(int step) {
        this.step = step;
    }

    public int getDir() {
        return dir;
    }

    public void setDir(int dir) {
        this.dir = dir;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void drawRole(Graphics graphics, JPanel jPanel) {
        graphics.drawImage(image, x * 32, y * 32, (x + 1) * 32, (y + 1) * 32, step * imgWidth, dir * imgHeight, (step + 1) * imgWidth, (dir + 1) * imgHeight, jPanel);
    }

    @Override
    public String toString() {
        return "Role{" +
                "image=" + image +
                ", imgWidth=" + imgWidth +
                ", imgHeight=" + imgHeight +
                ", step=" + step +
                ", dir=" + dir +
                ", x=" + x +
                ", y=" + y +
                '}';
    }

    abstract void move();

    abstract void annimal();

}
